package com.snacksmall.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.snacksmall.dao.ICartDao;
import com.snacksmall.model.Cart;
import com.snacksmall.service.CartService;
@Controller
@RequestMapping("/cart")
public class CartController {
	
	@Resource
	private CartService cartService;
	@Resource
	private ICartDao cartDao;
	
	@RequestMapping("/findAll.do")
	@ResponseBody
	public Object findAll(int user_id) {
		List<Cart> list=cartService.findAll(user_id);
		return list;
	}
	@RequestMapping("/addcart.do")
	@ResponseBody
	public int addcart(Cart cart) {
		return cartService.addcart(cart);
	}
	@RequestMapping("/addCartNum.do")
	@ResponseBody
	public int addcartnum(int cart_id,int cart_num) {
		return cartDao.addcartnum(cart_id, cart_num);
	}
	@RequestMapping("/del.do")
	@ResponseBody
	public int del(int id) {
		return cartService.del(id);
	}
}
